/*
 * cube_functions.h
 *
 *  Created on: Jan 28, 2012
 *      Author: a0272955
 */

#ifndef CUBE_FUNCTIONS_H_
#define CUBE_FUNCTIONS_H_

//*****************************************************************************
// 
//
//*****************************************************************************

#define REFRESH_RATE 480

#define NUM_LAYERS 8
#define NUM_ICS 4
#define NUM_LEDS_IC 16
#define LEDS_PER_LAYER  NUM_LAYERS*NUM_LAYERS

// LATCH port/pin
#define LATCH_PORT     GPIO_PORTK_BASE
#define LATCH_PIN      GPIO_PIN_4

// BLANK port/pin
#define BLANK_PORT     GPIO_PORTK_BASE
#define BLANK_PIN      GPIO_PIN_5


//LAYER port/pins
#define LAYER_PORT     GPIO_PORTD_BASE
#define LAYER_0_PIN    GPIO_PIN_0
#define LAYER_1_PIN    GPIO_PIN_1
#define LAYER_2_PIN    GPIO_PIN_2
#define LAYER_3_PIN    GPIO_PIN_3
#define LAYER_4_PIN    GPIO_PIN_4
#define LAYER_5_PIN    GPIO_PIN_5
#define LAYER_6_PIN    GPIO_PIN_6
#define LAYER_7_PIN    GPIO_PIN_7


// Some effects can render on different axis
// for example send pixels along an axis
// for better readability, we use the following predefined constants
#define AXIS_X 0x78
#define AXIS_Y 0x79
#define AXIS_Z 0x7a

extern unsigned long cube[NUM_LAYERS][NUM_LAYERS];
extern unsigned long cubeWrite[NUM_LAYERS][NUM_LAYERS];
extern unsigned long currentLayerGPIO[];
extern unsigned long g_ulLayerIndex;
extern int g_updateFlag;
extern unsigned long g_ulDataRx[];



//*****************************************************************************
//
//
//*****************************************************************************
extern unsigned long g_ulImageTime;
extern void WriteLayer(void);
extern void SetLayerState(unsigned long ulLayer,  unsigned char cstate);
extern void Send(unsigned long Data);
extern void ClearCube();
extern void SingleLED(int column, int row, int layer);
extern void animation2(unsigned long numLoops);
extern void InitLayers(void);
extern void switch_buff(void);
//extern unsigned long BStoH(char binaryString[]);
// TODO
/*
.
.
.
.
///////MORE FUNCTIONS
.
.
.
.
*/

#endif /* CUBE_FUNCTIONS_H_ */
